<#assign sec=JspTaglibs["/WEB-INF/tlds/spring-security.tld"]>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>洛卡网活动站后台</title>
	<link rel="stylesheet" type="text/css" href="${base}/js/lib/extjs/resources/css/ext-all.css"/>
	<script type="text/javascript" src="${base}/js/lib/extjs/adapter/ext/ext-base.js"></script>
	<script type="text/javascript" src="${base}/js/lib/extjs/ext-all-debug.js"></script>
	<script type="text/javascript" src="${base}/js/lib/extjs/ext-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${base}/admin/js/TabCloseMenu.js"></script>
	<script type="text/javascript">
	/************************ 所有的组件和面板 ************************/
	var headerBoxComponent = new Ext.BoxComponent({
		border: false,
		height: 44,
		el:'header',
		region: 'north',
		margins: '0 0 5 0'
	});
	
	var menuTreePanel = new Ext.tree.TreePanel({
		width: 150,
		collapsible: true,
		title: '功能菜单',
		region: 'west',
		split: true,
		root: {
			id: 'root',
			text: '系统导航'
		},
		loader: new Ext.tree.TreeLoader({
			method:"get",
			url:"${base}/admin/tree-menu.do"
		})
	});
	
	var contentTabPanel = new Ext.TabPanel({
		id:"contentTabPanel",
		frame:true,
		region:"center",
		plugins:new Ext.ux.TabCloseMenu()
	});
	
	function treeNodeClicked(node, e) {
		var contentPanel = Ext.getCmp("contentTabPanel");
		if (node.isLeaf()) {
			e.stopEvent();
			var item = contentPanel.getComponent(node.id);
			if (!item) {
				item = contentPanel.add({
						"id":node.id,
						"title":node.attributes.path,
						closable:true,
						autoWidth:true,
						height:530,
                        html:"<iframe onload=\"Ext.Msg.hide()\" id=\"iframe_"+node.id+"\" scrolling=\"auto\" frameborder=\"0\" width=\"100%\" height=\"100%\" src=\""+node.attributes.href+"\"></iframe>"
				});
				Ext.MessageBox.show({
					title:"信息",
					msg:"正在加载中...",
					progress:true,
					width:300,
					wait:true,
					waitConfig:{interval:200},
					closable:true
				});
				setTimeout(function(){Ext.MessageBox.hide()},5000);
            }
            contentPanel.setActiveTab(item);
		}
    }
	
	menuTreePanel.on("click", treeNodeClicked);
	
	MyViewportUi = Ext.extend(Ext.Viewport, {
		layout: {
			type: "border"
		},
	
		initComponent: function() {
			this.items = [
				headerBoxComponent,
				contentTabPanel,
				menuTreePanel
			];
			MyViewportUi.superclass.initComponent.call(this);
		}
	});
	
	MyViewport = Ext.extend(MyViewportUi, {
		initComponent: function() {
			MyViewport.superclass.initComponent.call(this);
		}
	});
	
	/************************ 装配面板，生成用户界面 ************************/
	Ext.onReady(function() {
		Ext.QuickTips.init();
		Ext.BLANK_IMAGE_URL = "${base}/js/lib/extjs/resources/images/default/s.gif";
		var cmp1 = new MyViewport({
			renderTo: Ext.getBody()
		});
		cmp1.show();
	});

	/************************ 自动走时功能 ************************/
	function startTimer(timestamp,controlID) {
		timestamp += 1000;
		var t = new Date(timestamp);
		var y = t.getFullYear();
		var mo = t.getMonth() + 1;
		var d = t.getDate();
		var h = t.getHours();
		var mi = t.getMinutes();
		var s = t.getSeconds();
		var w = t.getDay();
		if (mo < 10) mo = "0" + mo;
		if (d < 10) d = "0" + d;
		if (h < 10) h = "0" + h;
		if (mi < 10) mi = "0" + mi;
		if (s < 10) s = "0" + s;
		w = ["天","一","二","三","四","五","六"][w];
		var dateStr = y + "年" + mo + "月" + d + "日 " + h + ":" + mi + ":" + s + " 星期"+w;
		document.getElementById(controlID).innerHTML = dateStr;  //显示
		setTimeout(function(){
			startTimer(timestamp,controlID);
		}, 1000); //每秒刷新一次
	}
	
	Ext.onReady(function() {
		Ext.Ajax.request({
			url:"${base}/admin/get-date.do",
		    success:function(response,result){
                var timestamp = new Date().getTime();
                var str = response.responseText;
                if(str && /^\d+$/.test(str)) {
                	timestamp = parseInt(str);
                }else {
                	Ext.Msg.alert("提示","加载服务器时间错误，系统将显示客户端时间");
                }
                startTimer(timestamp,"datetime");
            },
            failure:function(){
                Ext.Msg.alert("提示","加载服务器时间失败，系统将显示客户端时间");
                var timestamp = new Date().getTime();
                startTimer(timestamp,"datetime");
            }
        });
		
	});
	</script>
</head>
<body>
<div id="header" style="font-size:12px;">
    <div style="float:left; margin-top: 15px;margin-left: 10px;color: #000">
        当前时间：<span id="datetime"></span>
    </div>
    <div style="float:right; margin-top: 15px;margin-right:10px;color: #000">
		尊敬的管理员<a href="#" style="padding:5px; text-decoration:none; color:#75BF0D; font-weight:bold; "><@sec.authentication property='principal.username' />:</a>您好！欢迎来到洛卡网活动站后台!
        <a href="${base}/index.do" style="padding:5px; text-decoration:none; color:#75BF0D;" target="_blank" >前台首页</a>|
        <a href="${base}/admin/index.do" style="padding:5px; text-decoration:none; color:#75BF0D;">去后台首页</a> | 
		<a href="${base}/logout.do" style="padding:5px; text-decoration:none; color:#75BF0D;">注销登陆</a> | 
    </div>
</div>
</body>
</html>